﻿@{
    Layout = "~/Views/Shared/_LayoutList.cshtml";
}
@(Html.nbGridFor<DishRangeView>(s =>
    {
        s.Action(Url.Action("LookUpList", new { orderId = ViewBag.OrderId, date = ViewBag.Date }));
        s.layoutH(86);
        s.DefaultSortOption("MealType", GridSortOrder.Asc);
        s.ShowCheckBox(false);
        s.SelectedOnClick(false);
        s.Columns(c =>
        {
            c.Bind(m => m.Id).IsKey();
            c.Bind(m => m.DishId).Hide();
            c.BindDateTime(m => m.Date).Title("日期");
            c.Bind(m => m.MealType).Title("餐单分类").Width(50).AsSearch();
            c.BindEnum(m => m.MainMaterialType, "MaterialCategory").Title("主料分类").Width(50).AsSearch();
            c.BindEnum(m => m.Category, "DishType").Title("类别").Width(30).AsSearch();
            c.Bind(m => m.Name).Title("菜肴名称").Width(100).AsQuery().AsSearch().Align(GridAlign.Left);
            c.Bind(m => m.Cost).Title("成本(元)").Width(40).Align(GridAlign.Right).AsSearch(SearchControlType.NumberBlock);
            c.Bind(m => m.ItemDesc).Title("品名信息").Width("auto").Align(GridAlign.Left).AsQuery();
            c.BindControl("Count").Title("客数").Width(60);
        });
        s.Buttons(b =>
        {
            b.BindSelectButton().OnClick("AddedDish");
            b.BindCancelButton();
        });
    }))
<script type="text/javascript">
    function AddedDish() {
        var result = [];
        var data = $("table.flexigrid").flexGetData();
        for (var rowIndex in data) {
            row = data[rowIndex];
            // 判断数量列是否有数字
            if (row.Count != "" && row.Count > 0) {
                result.push(row);
            }
        }
        CloseModalDialog(null, true, result);
    }
</script>
